import 'package:library_base/entities/workbench_entity.dart';
import 'package:library_base/net/apis.dart';
import 'package:library_base/network/http_config.dart';
import 'package:library_base/provider/base_controller.dart';
import 'package:get/get.dart';

class WorkbenchController extends BaseController {
  Rxn<WorkbenchEntity?> workbenchEntity = Rxn<WorkbenchEntity?>();

  String get purchaseCount =>
      workbenchEntity.value == null || workbenchEntity.value!.purchaseCount == 0
          ? '--'
          : workbenchEntity.value!.purchaseCount.toString();

  String get inquiredCount =>
      workbenchEntity.value == null || workbenchEntity.value!.unpaidCount == 0
          ? '--'
          : workbenchEntity.value!.unpaidCount.toString();

  String get warehousedCount =>
      workbenchEntity.value == null || workbenchEntity.value!.warehousedCount == 0
          ? '--'
          : workbenchEntity.value!.warehousedCount.toString();

  String get deliveredCount =>
      workbenchEntity.value == null || workbenchEntity.value!.deliveredCount == 0
          ? '--'
          : workbenchEntity.value!.deliveredCount.toString();

  @override
  Future requestData() {
    workbench();
    return super.requestData();
  }

  workbench() {
    if (baseState!.mounted) {
      requestUniversal<WorkbenchEntity>(Apis.WORKBENCH,
          isSendShowDialog: false, method: FBResultFul.GET, resultSuccessCall: (data) {
        workbenchEntity.value = data;
        update();
      });
    }
  }


}
